﻿using CAPlugin.Interface;
using SVS_C_SDK_COMLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace CAPlugin.Implement
{
    public class Client : IClient
    {
        private CSVS_C_SDK clientSdk = null;

        public Client() 
        {
            clientSdk = new CSVS_C_SDKClass();
        }

        public string Base64Decode(string inData)
        {
           return clientSdk.SOF_Base64Decode(inData);
        }

        public string Base64Encode(string inData)
        {
            return clientSdk.SOF_Base64Encode(inData) ;
        }

        public int CheckHH()
        {
            return clientSdk.SOF_CheckHH();
        }

        public int ClearPinCache()
        {
            return clientSdk.SOF_ClearPinCache();
        }

        public string DecryptData(string symmKey, string inData)
        {
            return clientSdk.SOF_DecryptData(symmKey, inData); ;
        }

        public int DecryptFile(string symmKey, string inFile, string outFile)
        {
            return clientSdk.SOF_DecryptFile(symmKey, inFile, outFile);
        }

        public string EncryptData(string symmKey, string inData)
        {
            return clientSdk.SOF_EncryptData(symmKey, inData);
        }

        public int EncryptFile(string symmKey, string inFile, string outFile)
        {
            return clientSdk.SOF_EncryptFile(symmKey, inFile, outFile);
        }

        public string EnvelopeDecrypt(string inData)
        {
            return clientSdk.SOF_EnvelopeDecrypt(inData);
        }

        public int EnvelopeDecryptFromFile(string inFile, string outFile)
        {
            return clientSdk.SOF_EnvelopeDecryptFromFile(inFile, outFile);
        }

        public string EnvelopeEncrypt(string certId, string inData)
        {
            return clientSdk.SOF_EnvelopeEncrypt(certId, inData);
        }

        public string EnvelopeEncryptEx(string certB64, string inData)
        {
            return clientSdk.SOF_EnvelopeEncryptEx(certB64, inData);
        }

        public int EnvelopeEncryptFromFile(string certId, string inFile, string outFile)
        {
            return clientSdk.SOF_EnvelopeEncryptFromFile(certId, inFile, outFile);
        }

        public string ExportUserCert(string certId)
        {
            return clientSdk.SOF_ExportUserCert(certId);
        }

        public int GetCertCount()
        {
            return clientSdk.SOF_GetCertCount();
        }

        public string GetCertInfo(string certId, short sType)
        {
            return clientSdk.SOF_GetCertInfo(certId, sType);
        }

        public string GetCertInfoByOid(string certId, string oid)
        {
            return clientSdk.SOF_GetCertInfoByOid(certId, oid);
        }

        public string GetCertInfoByOidEx(string strBase64, string strOid)
        {
            return clientSdk.SOF_GetCertInfoByOidEx(strBase64, strOid);
        }

        public string GetCertInfoEx(string strBase64, short sType)
        {
            return clientSdk.SOF_GetCertInfoEx(strBase64, sType);
        }

        public string GetEncryptMethod()
        {
            return clientSdk.SOF_GetEncryptMethod();
        }

        public string GetErrorMsg()
        {
            return clientSdk.SOF_GetErrorMsg();
        }

        public string GetHashMentod()
        {
            return clientSdk.SOF_GetHashMethod();
        }

        public string GetKeySN(string certID)
        {
            return clientSdk.SOF_GetKeySN(certID); 
        }

        public string GetP7SignDataInfo(string P7Data, short sType)
        {
            return clientSdk.SOF_GetP7SignDataInfo(P7Data, sType);
        }

        public string GetUserList()
        {
            if (clientSdk == null)
            {
                Console.WriteLine("clientSdk为空，未将对象引用设置到对象实例");
            }
            return clientSdk.SOF_GetUserList();
        }

        public string GetVersion()
        {
            return clientSdk.SOF_GetVersion();
        }

        public string GetXMLSignatureInfo(string xmlSignedData, short sType)
        {
            return clientSdk.SOF_GetXMLSignatureInfo(xmlSignedData, sType);
        }

        public string HashData(string inData)
        {
            return clientSdk.SOF_HashData(inData);
        }

        public int Login(string certId, string userPin)
        {
            return clientSdk.SOF_Login(certId, userPin);
        }

        public int ModifyUsbKeyPIN(string oldPin, string newPin)
        {
            return clientSdk.SOF_ModifyUsbKeyPIN(oldPin, newPin);
        }

        public int P7SignFromFile(string certId, string inFile, string outFile)
        {
            return clientSdk.SOF_P7SignFromFile(certId, inFile, outFile);
        }

        public int P7SignFromFileEx(string certId, string inFile, string outFile)
        {
            return clientSdk.SOF_P7SignFromFileEx(certId, inFile, outFile);
        }

        public int P7VerifyFromFile(string inFile, string outFile)
        {
            return clientSdk.SOF_P7VerifyFromFile(inFile, outFile);
        }

        public string P7VerifyFromFileEx(string inFile, string outFile)
        {
           return clientSdk.SOF_P7VerifyFromFileEx(inFile, outFile);
        }

        public string PriKeyDecrypt(string certId, string inData)
        {
           return clientSdk.SOF_PriKeyDecrypt(certId, inData);
        }

        public int PriKeyDecryptFile(string certId, string inFile, string outFile)
        {
            return clientSdk.SOF_PriKeyDecryptFile(certId, inFile, outFile);
        }

        public string PubKeyEncrypt(string certId, string inData)
        {
           return clientSdk.SOF_PubKeyEncrypt(certId, inData);
        }

        public string PubKeyEncryptEx(string certB64, string inData)
        {
            return clientSdk.SOF_PubKeyEncryptEx(certB64, inData);
        }

        public int PubKeyEncryptFile(string cetrId, string inFile, string outFile)
        {
           return clientSdk.SOF_PriKeyDecryptFile(cetrId, inFile, outFile); 
        }

        public string SelectCert()
        {
            return clientSdk.SOF_SelectCert();
        }

        public void SetCertAppPolicy(string appPolicy)
        {
             clientSdk.SOF_SetCertAppPolicy(appPolicy);
        }

        public int SetCertFilter(int certFilterFlag, string certFilter)
        {
            return clientSdk.SOF_SetCertFilter(certFilterFlag, certFilter);
        }

        public int SetEncryptMethod(string encryptMethod)
        {
            return clientSdk.SOF_SetEncryptMethod(encryptMethod);
        }

        public int SetHashMethod(string hashMenthod)
        {
            return clientSdk.SOF_SetHashMethod(hashMenthod);
        }

        public int SetP7SignMode(short sMode)
        {
            return clientSdk.SOF_SetP7SignMode(sMode);
        }

        public string SignData(string certId, string inData)
        {
            return clientSdk.SOF_SignData(certId, inData);
        }

        public string SignDataByP7(string certId, string inData)
        {
           return clientSdk.SOF_SignDataByP7(certId, inData);
        }

        public string SignDataXML(string certId, string inData)
        {
            return clientSdk.SOF_SignDataXML(certId, inData);
        }

        public string SignEnvelopeDecrypt(string inData)
        {
            return clientSdk.SOF_SignEnvelopeDecrypt(inData);
        }

        public int SignEnvelopeDecryptFromFile(string inFile, string outFile)
        {
            return clientSdk.SOF_SignEnvelopeDecryptFromFile(inFile, outFile);
        }

        public string SignEnvelopeEncrypt(string signedCertID, string encryptedCertId, string inData)
        {
            return clientSdk.SOF_SignEnvelopeEncrypt(signedCertID, encryptedCertId, inData);    
        }

        public int SignEnvelopeEncryptFromFile(string signedCertId, string encryedCertId, string inFile, string outFile)
        {
            return clientSdk.SOF_SignEnvelopeEncryptFromFile(signedCertId, encryedCertId, inFile, outFile);
        }

        public string SignFile(string certId, string inFile)
        {
            return clientSdk.SOF_SignFile(certId, inFile);
        }

        public int ValidateCert(string certId)
        {
            return clientSdk.SOF_ValidateCert(certId);
        }

        public string VerifyAttachSigned(string inData)
        {
            return clientSdk.SOF_VerifyAttachSigned(inData);
        }

        public int VerifySignedData(string certId, string inData, int inDataLength, string signValue)
        {
            return clientSdk.SOF_VerifySignedData(certId, inData, inDataLength, signValue); 
        }

        public int VerifySignedDataByP7(string P7Data, string srcData)
        {
            return clientSdk.SOF_VerifySignedDataByP7(P7Data, srcData);
        }

        public int VerifySignedDataXML(string inData)
        {
            return clientSdk.SOF_VerifySignedDataXML(inData);
        }

        public int VerifySignedFile(string certId, string inFile, string signValue)
        {
            throw new NotImplementedException();
        }

        public string GenRandom(short length)
        { 
           return clientSdk.SOF_GenRandom(length);
        }
    }
}
